from rest_framework.viewsets import ModelViewSet
from rest_framework.generics import ListAPIView
from django.contrib.auth.models import Permission
from django.contrib.auth.models import ContentType

from meiduo_admin.utils import PaginatorShow
from meiduo_admin.serializers.authManageSeriaizer import PermissionTypeSerializer
from meiduo_admin.serializers.authManageSeriaizer import PermissionSerializer
from meiduo_admin.permissions import *


class PermissionView(ModelViewSet):
    queryset = Permission.objects.all().order_by("id")
    serializer_class = PermissionSerializer
    permission_classes = [IsSuperUser]

    pagination_class = PaginatorShow


class PermissionTypeView(ListAPIView):
    queryset = ContentType.objects.all()
    serializer_class = PermissionTypeSerializer
    permission_classes = [IsSuperUser]


